<template>
    <div>
        <el-form :model="ruleForm" ref="ruleForm" :label-position="labelPosition" label-width="120px" class="demo-ruleForm">
        <div class="container">
            <h4 style="margin-bottom: 20px">{{ruleForm.supplierName}}</h4>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="所在地区：">
                        {{area}}
                    </el-form-item>
                    <el-form-item label="联系人姓名：">
                        {{ruleForm.userName}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="详细地址：">
                        {{ruleForm.address}}
                    </el-form-item>
                    <el-form-item label="联系方式：">
                        {{ruleForm.phone}}
                    </el-form-item>
                </el-col>
            </el-row>
        </div>
        </el-form>
        <div class="container" style="margin-top:20px">
            <h3 style="margin-bottom: 20px">供货信息</h3>
            <el-table
                :data="tableData"
                border
                ref="multipleTable"
                header-cell-class-name="table-header"
            >
                <el-table-column prop="inTime" sortable label="入库时间"></el-table-column>
                <el-table-column prop="breedName" sortable label="品名"></el-table-column>
                <el-table-column prop="totalNum" sortable label="数量">
                    <template slot-scope="scope">
                        
                            
                            
                        {{scope.row.totalNum}}{{scope.row.units}}
                        
                    </template>
                </el-table-column>
                <!-- <el-table-column prop="" sortable label="规格"></el-table-column> -->
            </el-table>
            <!-- <el-pagination layout="total, prev, pager, next, jumper" hide-on-single-page="value" :total="total" style="margin-top:20px; text-align:center;"></el-pagination> -->
            <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPage"  @current-change="handleCurrentChange" :total="total" style="margin-top:20px"></el-pagination>
        </div>
    </div>
</template>

<script>
    import {supplier_findById,supplier_checklist} from '@/request/api'
    import {regionData,CodeToText} from 'element-china-area-data'
    export default {
        data() {
            return {
                total:0,
                value:true,
                area:'',
                city:'',
                pagesize:10,
                
                currentPage:1,
                labelPosition:'right',
                ruleForm: {},
                tableData: [
                   
                ],

            };
        },
        mounted(){
            this.id = this.$route.query.id
            if(this.id == undefined){
                
            }else{
                this.init()
            }
        },
        methods: {
            handleCurrentChange(){

            },
            handlecheck(){

            },
            init(){
                supplier_findById(this.id).then((res)=>{
                    this.ruleForm = res.data
                    this.city = res.data.area.split(",")
                    var arr = ""
                    for (let i = 0; i < this.city.length; i++) {
                        arr += CodeToText[this.city[i]] + "/" 
                        
                    }
                    this.area = arr.substr(0,arr.length-1)
                })
                supplier_checklist(this.id).then((res)=>{
                    this.tableData = res.data
                   
                    // this.area = arr.substr(0,arr.length-1)
                })
            },
            backPage () {
                this.$router.go(-1);
            },

        }
    }
</script>
<style scoped lang="less">
 .el-pagination{
    text-align: center;
} 
</style>